<?php
require_once './include/conn.php';
$name_1 = $_GET['name'];
$id = intval($_GET['id']);
if(strlen($name_1) > 0){
	$name_2 = $name_1;
}else{
	$name_2 = getUserIP();
}
if($id<=0){
    header("location:http://www.baidu.com");
}else{
    $good = $db->get_one("select * from `h_goods` where id = '{$id}'");
}
if(!$good){
    header("location:http://www.baidu.com");
}
$good["headimg"] = substr($good["headimg"],3);
if(!$good['url']){
    $good['url'] = 'javascript:;';
}
setcookie("name", $name_2,NULL,'/');
$h_user = $_COOKIE['name'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>在线客服</title>
	<link rel="stylesheet" href="style.css">
	<link rel="stylesheet" href="title.css">
	<link rel="stylesheet" href="/iconfont/iconfont.css">
</head>
<body>
	<div class="service">
	    <div class="msg-head text-center">
			<a href="javascript:;" onclick="history.go(-1);"><i class="iconfont iconunie679"></i></a>
			    <span style="background:white;color:#05b4ff;padding:0px 6px;font-size: 18px;font-weight:500;border-radius: 14px;border:1px solid #05b4ff;">卖家</span>
			    <span style="font-size:24px"><b><?=$good['name']?></b></sapn>
	    </div>
	    <div class="msg-head text-center" style="height:60px;padding-bottom:50px;">
	        <div class="userchat-goods">
				<div>
				    <img style="margin-left: 30px;height: 80px; width:80px;" src="<?=$good['headimg']?>" class="sup-h">
				</div>
				<div style="margin-left:5px;margin-top: -40px;">
	                <span style="background:#05b4ff;color:white;padding:0 5px;font-size: 15px;margin-right:5px;">帐号</span><?=$good['account']?><br>
		            <span class="format-price">
		                <span class="currency-symbol price-14">￥</span>
		                <span class="integer-part price-14"><?=$good['price']?></span>
		            </span>
				</div>
				<div style="position: absolute;right: 15px;">
				    <a style="padding: 8px 15px;
    height: 0.74667rem;
    line-height: .74667rem;border-radius: 20px;position:relative;color:white;background: #05b4ff;" href="<?=$good['url']?>">立即购买</a>
				</div>
			</div>
	    </div>
		<div class="msg-box">
		    <!--<div class="msg clearfix">
				<div class="img1">
					<img src="img/kefu.png" alt="" width="100%">
				</div>
				<div class="img2">
					<img src="img/user.png" alt="" width="100%">
				</div>
				<div class="content">
					<span id="first-msg"></span>
					<div class="indicate left-indicate"></div>
					<div class="indicate right-indicate"></div>
				</div>
			</div>-->
			<?php
				$rs = $db->get_one("select count(*) as tj from `h_kefu` where h_user = '{$h_user}' and h_who = 2 and h_isread = 0");
				if($rs['tj'] > 0){
					$query = "select * from `h_kefu` where h_user = '{$h_user}' and h_isread = 1 order by h_addTime asc,id asc";
					$result = $db->query($query);
					while($rs_list = $db->fetch_array($result))
					{	
						if($rs_list['h_who'] == 2){
							echo '
								<div class="msg clearfix">
									<div class="img1">
										<img src="img/kefu.png" alt="" width="100%">
									</div>
									<div class="img2">
										<img src="img/user.png" alt="" width="100%">
									</div>
									<div class="content">
										<span>' . $rs_list['h_content'] . '</span>
										<div class="indicate left-indicate"></div>
										<div class="indicate right-indicate"></div>
									</div>
								</div>
							';
						} else {
							echo '
								<div class="msg clearfix on">
									<div class="img1">
										<img src="img/kefu.png" alt="" width="100%">
									</div>
									<div class="img2">
										<img src="img/user.png" alt="" width="100%">
									</div>
									<div class="content">
										<span>' . $rs_list['h_content'] . '</span>
										<div class="indicate left-indicate"></div>
										<div class="indicate right-indicate"></div>
									</div>
								</div>
							';
						}
					}
                }else if($rs['tj'] == 0){
					$query = "select * from `h_kefu` where h_user = '{$h_user}' order by h_addTime asc,id asc";
					$result = $db->query($query);
					while($rs_list = $db->fetch_array($result))
					{	
						if($rs_list['h_who'] == 2){
							echo '
								<div class="msg clearfix">
									<div class="img1">
										<img src="img/kefu.png" alt="" width="100%">
									</div>
									<div class="img2">
										<img src="img/user.png" alt="" width="100%">
									</div>
									<div class="content">
										<span>' . $rs_list['h_content'] . '</span>
										<div class="indicate left-indicate"></div>
										<div class="indicate right-indicate"></div>
									</div>
								</div>
							';
						}else{
							echo '
								<div class="msg clearfix on">
									<div class="img1">
										<img src="img/kefu.png" alt="" width="100%">
									</div>
									<div class="img2">
										<img src="img/user.png" alt="" width="100%">
									</div>
									<div class="content">
										<span>' . $rs_list['h_content'] . '</span>
										<div class="indicate left-indicate"></div>
										<div class="indicate right-indicate"></div>
									</div>
								</div>
							';
						}
					}
				}
			?>
			<p id="msgzone"></p>
		</div>  
		<div class="msg-post" style="display:flex;
    justify-content: space-between; padding: 20px 20px 10px 20px;
    ">
		    <div style="width:14%;">
    			    	
    				<label for="file"><!--<i class="iconfont icontupian"></i>-->
    				    <svg t="1670818581063" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4596" width="44" height="44"><path d="M335.36 440.32c38.4 0 71.68-30.72 71.68-71.68 0-38.4-30.72-71.68-71.68-71.68-38.4 0-71.68 30.72-71.68 71.68 2.56 40.96 33.28 71.68 71.68 71.68z m0 0M652.8 396.8L445.44 691.2 337.92 540.16 158.72 793.6h704L652.8 396.8z m0 0" p-id="4597" fill="#2c2c2c"></path><path d="M934.4 107.52H89.6c-20.48 0-35.84 15.36-35.84 35.84V883.2c0 20.48 15.36 35.84 35.84 35.84h844.8c20.48 0 35.84-15.36 35.84-35.84V143.36c0-20.48-15.36-35.84-35.84-35.84z m-35.84 739.84H125.44V176.64h775.68v670.72h-2.56z m0 0" p-id="4598" fill="#2c2c2c"></path></svg>
    				</label>
    				<input type="file" accept="image/*" id="file" onchange="upload()">
                
    			</div>
		    <div style="width:80%;">
		        <textarea placeholder="用户已关闭对外聊天功能" id="cont" style="background-color:#F5F7FA;width:98%;"></textarea>
		    </div>
    			
    		<div>
    		    <input type="button" value="发送" onclick="comment();" style="height: 44px;
    line-height: 44px;
    background-color: #C0C4CC;font-size:20px;padding: 0 22px;border-radius: 22px;">
    		</div>
    			
		</div>
	</div>
    <script src="js/jquery.min.js"></script>
	<script src="layer/layer.js"></script>
	<script src="js/index.js"></script>
</body>
</html>